home *** CD-ROM | disk | FTP | other *** search
- class classes.misc.PowerUp
- {
- var x;
- var y;
- var type;
- var id;
- var clip;
- var xMov;
- var yMov;
- var f2 = "checkHit";
- var c = 0;
- var yank = false;
- var weapon = false;
- var Name = "powerUp";
- function PowerUp(px, py, ptype, pid)
- {
- this.x = px;
- this.y = py;
- this.type = ptype;
- this.id = pid;
- _root.d = _root.d + 1;
- this.clip = _root.attachMovie("powerUp","powerUp" + this.id + "Clip",_root.d);
- this.clip._x = this.x;
- this.clip._y = this.y;
- this.clip.gotoAndStop(this.type);
- var _loc3_ = _root.getAngleRad2(this.x,this.y,500,300);
- this.xMov = Math.cos(_loc3_) * _root.randRange2(0.5,2.5);
- this.yMov = Math.sin(_loc3_) * _root.randRange2(0.5,2.5);
- if(this.type == "doubleLaserA" || this.type == "tripleLaserA" || this.type == "twistLaser" || this.type == "tripleTwistLaser" || this.type == "rapidLaser" || this.type == "bigLaser")
- {
- this.weapon = true;
- }
- }
- function hit()
- {
- if(this.weapon)
- {
- _root.audio.playLevel3("weaponUpgrade",25);
- }
- else if(this.type.charAt(0) == "g")
- {
- _root.audio.playLevel3("gem" + (random(3) + 1),_root.randRange(20,30));
- }
- else if(this.type.substr(0,10) == "speedBoost")
- {
- _root.audio.playLevel3("speedBoost",_root.randRange(29,35));
- }
- else if(this.type.substr(0,11) == "weaponBoost")
- {
- _root.audio.playLevel3("weaponBoost",_root.randRange(29,35));
- }
- else if(this.type.substr(0,6) == "shield")
- {
- _root.audio.playLevel3("shield2",_root.randRange(29,35));
- }
- else
- {
- _root.audio.playLevel3(this.type,_root.randRange(29,35));
- }
- this.clip[this.type].gotoAndPlay("hit");
- this.f2 = "ending";
- }
- function ending()
- {
- if(this.clip.end)
- {
- this.yank = true;
- }
- }
- function checkHit()
- {
- if(this.weapon)
- {
- if(this.clip[this.type].hitClip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].powerUp(this.type);
- this.hit();
- }
- }
- else if(this.clip.hitTest(_root[_root.char + "Clip"]))
- {
- _root[_root.char].powerUp(this.type);
- this.hit();
- }
- }
- function main()
- {
- this.c = this.c + 1;
- this[this.f2]();
- if(this.c > 30 && this.type == "smartBomb")
- {
- var _loc4_ = 0;
- var _loc6_ = _root.broShots.length;
- while(_loc4_ < _loc6_)
- {
- var _loc5_ = _root.broShots[_loc4_] + "Clip";
- if(this.clip.hitTest(_root[_loc5_]))
- {
- var _loc3_ = _root.broShots[_loc4_];
- this.xMov += _root[_loc3_].xMov / 20;
- this.yMov += _root[_loc3_].yMov / 20;
- _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
- _root[_loc3_].exploX = this.x + this.clip._width / 2;
- _root[_loc3_].exploY = this.y + this.clip._height / 2;
- _root[_loc3_].hit();
- _root[_root.char].powerUp(this.type);
- this.hit();
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- if(this.x > 1050 || this.x < -50 || this.y < -50 || this.y > 650)
- {
- this.yank = true;
- }
- if(this.yank)
- {
- _root.removePowerUp("powerUp" + this.id);
- }
- this.x += this.xMov;
- this.y += this.yMov;
- this.clip._x = this.x;
- this.clip._y = this.y;
- }
- }
-